﻿using System;
using System.Configuration;

namespace DuLabs.Classic.Configuration
{
    public class ParamElementCollection : ConfigurationElementCollection
    {
        protected override ConfigurationElement CreateNewElement()
        {
            return new ParamElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            if (element == null)
            {
                return null;                
            }

            return (element as ParamElement).Name;
        }

        public new ParamElement this[string name]
        {
            get
            {
                return this.BaseGet(name) as ParamElement;
            }
        }

        public ParamElement this[int index]
        {
            get
            {
                return this.BaseGet(index) as ParamElement;
            }
        }

        protected override string ElementName
        {
            get
            {
                return "param";
            }
        }

        public override ConfigurationElementCollectionType CollectionType
        {
            get
            {
                return ConfigurationElementCollectionType.BasicMap;
            }
        }
    }
}
